package me.keiwu.user.dao;

import me.keiwu.user.domain.Comment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * Created by kei on 02/02/2018.
 */
public interface CommentDao extends JpaRepository<Comment, Long>, JpaSpecificationExecutor<Comment> {

    @Query(value = "select * from comment where (owner=?1 and commenter=?2) or (owner=?2 and commenter=?1) limit 1", nativeQuery = true)
    Comment findByOwnerAndCommenter(Long owner, Long commenter);
}
